#pragma once

#include "TerrainType.h"
#include "../Math/Vec2i.h"
#include "../Math/Vec3f.h"
#include <memory>

class Tree;
typedef std::shared_ptr<Tree> TreePtr;

class MapCell
{
public:
	MapCell(const Vec2i &pos, float altitude, float slope, const Vec3f &normal);
	MapCell(Vec2i &&pos, float altitude, float slope, Vec3f &&normal);
	MapCell(int x, int y, float altitude, float slope, const Vec3f &normal);
	~MapCell();

	TerrainTypePtr terrainType;

	const Vec2i &getPos() const { return pos; }
	float getAltitude() const { return altitude; }
	float getSlope() const { return slope; }
	const Vec3f &getNormal() const { return normal; }

	void setWalkable(bool flag) { walkable = flag; }
	bool isWalkable() const { return walkable; }

	void setTreePlanted(const TreePtr &tree = nullptr) { can_plant_tree = false; this->tree = tree; }
	bool canPlantTree() const { return can_plant_tree; }
	const TreePtr &getTree() const { return tree; }

private:
	Vec2i pos;
	float altitude;
	float slope;
	Vec3f normal;
	bool walkable;
	bool can_plant_tree;
	TreePtr tree;
};
typedef std::shared_ptr<MapCell> MapCellPtr;
